package com.Questions.DFS;


/**
 * 找出克隆二叉树中相同节点
 */
public class leetcode1379 {
    public final TreeNode getTargetCopy(final TreeNode original, final TreeNode cloned, final TreeNode target) {
        TreeNode ans=new TreeNode();
        ans.val=999;
        return DFS(cloned,target.val,ans);

    }

    public TreeNode DFS(TreeNode cloned,int target,TreeNode ans){
        if(cloned==null){
            return null;
        }
        if(cloned.val==target){
            return cloned;
        }
        TreeNode left=DFS(cloned.left,target,ans);
        if(left!=null){
            return left;
        }
        return DFS(cloned.right,target,ans);


    }


}
